﻿$(function () {
    var dataTable = $('#MachinesTable').DataTable(abp.libs.datatables.normalizeConfiguration({
        ajax: abp.libs.datatables.createAjax(rechargeable.machines.serialNumber.getList, inputAction),
        processing: true,
        serverSide: true,
        paging: true,
        searching: false,
        autoWidth: false,
        scrollCollapse: true,
        order: [[2, "desc"]],
        columnDefs: [
            { data: "id" },
            { data: 'machineId' },
            { data: "creationTime" },
            { data: "expire" },
            { data: "useTime" },
            { data: "createDesc" }
        ]
    }));

    getNotUseCount();

    $("#btnSearch").on("click", function () {
        console.log("搜索");
        getNotUseCount();
        dataTable.ajax.reload();
    });
});

function getNotUseCount() {
    rechargeable.machines.serialNumber.getNotUseCount(inputAction()).done(function (data) {
        console.log(data);
        $("#notUseCount").html(data);
    });
}

function inputAction() {
    return {
        productId: $("#Products").val(),
        key: $("#key").val()
    };
}